#!/bin/bash

if ls *.json >/dev/null 2>&1; then
	if [ -f "/etc/v2ray/config.json.bak" ]; then
	   echo "copy a config setting json."
	   cp ./*.json /etc/v2ray/config.json
	else
	   echo "it isn't exit, need to backup the config file"
	   sudo cp /etc/v2ray/config.json /etc/v2ray/config.json.bak
	   cp ./*.json /etc/v2ray/config.json
	fi
else
   echo "there don't have json file."

fi

service v2ray stop
service v2ray restart

# 设置 http/https 代理
# 10809 是v2ray 常用代理端口
proxy_ip=127.0.0.1:10808

export http_proxy=http://$proxy_ip
export https_proxy=http://$proxy_ip

# 取消 http/https 代理
#unset  http_proxy
#unset  https_proxy


# 设置 git 代理 socks5
git config --global http.proxy socks5://$proxy_ip
git config --global https.proxy socks5://$proxy_ip

# 设置 git 代理 http
#git config --global http.proxy http://$proxy_ip
#git config --global https.proxy https://$proxy_ip

# 取消 git 代理
#git config --global --unset http.proxy
#git config --global --unset https.proxy


